package com.zenchn.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/***
 * 通用审核状态类型 枚举
 * @author dingxinfa
 * @date 2018-11-27
 */
public enum CommonVerifyStatusEnum {

    /** 删除 **/
    NOT_PASS(-1,"审核不通过"),
    /** 停用 **/
    AWAITS(0,"待审核"),
    /** 启用 **/
    PASS(1,"审核通过");

    /**code**/
    private Integer code;
    /**中文描述**/
    private String desc;


    CommonVerifyStatusEnum(Integer code, String desc){
        this.code = code;
        this.desc = desc;
    }

    public static CommonVerifyStatusEnum getCommonVerifyStatusEnum(String code){
        for (CommonVerifyStatusEnum e : values()) {
            Integer currCode=e.getCode();
            if(currCode.equals(code)){
                return e;
            }
        }
        return null;
    }


    /**
     * 获取 所有状态列表
     */
    public static List<Map> getAllList() {
        List<Map> valueList=new ArrayList<>();
        for (CommonVerifyStatusEnum categoryCode : values()) {
            Map<String,Object> code=new HashMap<>(2);
            code.put("code",categoryCode.getCode());
            code.put("desc",categoryCode.getDesc());
            valueList.add(code);
        }
        return valueList;
    }


    /**
     * 获取 正常状态列表
     */
    public static List<Map> getNormalList() {
        List<Map> valueList=new ArrayList<>();
        for (CommonVerifyStatusEnum categoryCode : values()) {
            if (categoryCode.getCode()>=0) {
                Map<String, Object> code = new HashMap<>(2);
                code.put("code", categoryCode.getCode());
                code.put("desc", categoryCode.getDesc());
                valueList.add(code);
            }
        }
        return valueList;
    }


    public static String getDesc(Integer code){
        for (CommonVerifyStatusEnum e : values()) {
            Integer currCode=e.getCode();
            if(currCode.equals(code)){
                return e.getDesc();
            }
        }
        return "";
    }


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }
}
